package com.app;

import com.app.server.Server;
import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.web.client.RestTemplate;


@Slf4j
@SpringBootApplication
@ServletComponentScan(basePackages ="com.app.config.SqlInjectFilter")
@MapperScan("com.app.mapper")
@EnableTransactionManagement
@EnableScheduling
public class ShopAllianceApplication {
	public static void main(String[] args) {
		ConfigurableApplicationContext context = SpringApplication.run(ShopAllianceApplication.class, args);
		context.getBean(Server.class).start();
		log.info("项目启动成功");
	}
	@Bean
	public RestTemplate restTemplate(RestTemplateBuilder builder) {
		RestTemplate restTemplate = builder.build();
		restTemplate.getMessageConverters().add(new MappingJackson2HttpMessageConverter());
		return restTemplate;
	}
}
